package com.example.config;

import com.example.service.TokenStoreService;
import com.example.service.impl.TokenStoreServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
public class TokenConfig {

    @Bean
    @ConditionalOnBean(StringRedisTemplate.class)
    @ConditionalOnProperty(prefix = "app.redis", name = "enabled", havingValue = "true")
    public TokenStoreService tokenStore(StringRedisTemplate template) {
        return new TokenStoreServiceImpl(template);
    }
}


